import { createRouter, createWebHistory } from "vue-router";

const Layout = () => import(/* webpackChunkName: "home" */ "@/views/HomeView");
const Header = () => import(/* webpackChunkName: "home" */ "@/views/home/components/HearderTop.vue");
const manageLayout = () => import("@/views/manage");

const routes = [
  //首页
  {
    path: "/",
    name: "home",
    component: Layout,
    redirect: "/home/index",
    children: [
      {
        path: "/home/index",
        name: "home",
        component: () => import("@/views/home/index")
      }
    ]
  },
  //商品详情
  {
    path: "/shopDetail",
    name: "shopDetail",
    redirect: "/shopDetail/index",
    children: [
      {
        path: "/shopDetail/index",
        name: "shopDetail",
        component: () => import("@/views/shopDetail/index")
      }
    ]
  },
  //商品类目
  {
    path: "/shopCategories",
    name: "shopCategories",
    redirect: "/shopCategories/index",
    children: [
      {
        path: "/shopCategories/index",
        name: "shopCategories",
        component: () => import("@/views/shopCategories/index")
      }
    ]
  },
  //关键词搜索
  {
    path: "/search",
    name: "search",
    component: Header,
    children: [
      {
        path: "searchkey",
        name: "searchkey",
        component: () => import("@/views/home/searchkey")
      }
    ]
  },
  //预算报价
  {
    // path: "/quote-price",
    // name: "quote-price",
    // component: () => import("@/views/quote-price/following")

    path: "/quote-price",
    name: "quote-price",
    component: Header,
    redirect: "/quote-price/following",
    meta: {
      title: "预算报价"
    },
    children: [
      {
        path: "following",
        name: "following",
        component: () => import("@/views/quote-price/following"),
        meta: {
          title: "跟进中",
          num: "followingTotal"
        }
      },
      {
        path: "following/list",
        name: "following/list",
        component: () => import("@/views/quote-price/list"),
        meta: {
          title: "预算报价明细",
          show: false
        }
      },
      {
        path: "following/change",
        name: "following/change",
        component: () => import("@/views/quote-price/change"),
        meta: {
          title: "预算报价变更",
          show: false
        }
      },
      {
        path: "following/exchange",
        name: "following/exchange",
        component: () => import("@/views/quote-price/exchange"),
        meta: {
          title: "预算退换补单",
          show: false
        }
      },
      {
        path: "following/exchangeHistory",
        name: "following/exchangeHistory",
        component: () => import("@/views/quote-price/exchangeHistory"),
        meta: {
          title: "变更单详情",
          show: false
        }
      }
      // {
      //   path: "signed",
      //   name: "signed",
      //   meta: {
      //     title: "已签约"
      //   }
      // },
      // {
      //   path: "finished",
      //   name: "finished",
      //   meta: {
      //     title: "已完成单"
      //   }
      // },
      // {
      //   path: "useless",
      //   name: "useless",
      //   meta: {
      //     title: "废单"
      //   }
      // }
    ]
  },

  //套餐报价
  {
    path: "/combo-price",
    name: "comboPprice",
    component: Header,
    redirect: "/combo-price/index",
    children: [
      {
        path: "/combo-price/index",
        name: "comboprice",
        component: () => import("@/views/combo-price/index")
      },
      {
        path: "/combo-price/details",
        name: "comboDetails",
        component: () => import("@/views/combo-price/details")
      }
    ]
  },
  //帮助中心
  {
    path: "/help-center",
    name: "help-center",
    component: () => import("@/views/helpCenter/help")
  },
  {
    path: "/manage",
    name: "manage",
    component: () => import("@/layout/index"),
    meta: {
      title: "账户管理中心",
      show: true
    },
    children: [
      {
        path: "/trade",
        name: "trade",
        component: manageLayout,
        meta: {
          title: "交易管理",
          show: false
        },
        children: [
          {
            path: "/manage/orderlist",
            name: "orderlist",
            component: () => import("@/views/manage/orderlist/index"),
            meta: {
              title: "商品订单",
              breadcrumbColor: true,
              num: "orderlistTotal",
              show: true
            }
          },
          {
            path: "/manage/orderlist/detail",
            name: "orderlist-detail",
            component: () => import("@/views/manage/orderlist/detail.vue"),
            meta: {
              title: "商品订单详情",
              breadcrumbColor: true,
              breadcrumbShow: true,
              show: false
            }
          },
          {
            path: "/manage/collection",
            name: "collection",
            component: () => import("@/views/manage/collection/index"),
            meta: {
              title: "我的收藏",
              breadcrumbColor: true,
              num: "collectionTotal",
              show: true
            }
          }
        ]
      },
      {
        path: "account",
        name: "account",
        component: manageLayout,
        meta: {
          title: "账户管理",
          breadcrumbColor: true
        }
      },
      {
        path: "serve",
        name: "serve",
        component: manageLayout,
        meta: {
          title: "服务管理",
          breadcrumbColor: true
        }
      }
    ]
  }
];

const router = createRouter({
  history: createWebHistory(window.__MICRO_APP_BASE_ROUTE__ || "/"),
  routes
});

export default router;
